<?php defined('MINICAKE') or exit('can not access!');
/**
 * 没有实例化的加载类
 *
 * @param unknown_type $class
 * @return unknown
 */
function import_class($class){
	if(file_exists(APP.'lib/'.$class.'.php')){
		require_once(APP.'lib/'.$class.'.php');
		return true;
	}else if(file_exists(MINICAKE.'lib/'.$class.'.php')){
		require_once(MINICAKE.'lib/'.$class.'.php');
		return true;
	}else{
		return false;
	}
}

function minicake_exception_handler($e){
	$file = $e->getFile();
	$line = $e->getLine();
	$message = $e->getMessage();
	if(Configure::getItem('environment') === "SAE"){
		sae_debug("$message $file $line");
	}
	ob_start();
	if(Configure::getItem('debug') === true) {
		include_once(APP.'views/errors/debug.php');
	}else{
		$error_type = trim(array_shift($message));
		switch ($error_type){
			case 404:
				include_once(APP.'views/errors/404.php');
				break;
			default:
				include_once(APP.'views/errors/error.php');
				break;
		}
	}
	// $buffer = ob_get_contents();
	ob_end_flush();
	// echo $buffer;
}
?>
